<?php
/*
 *  Rock Band Stats(C) 2008  Tea Figuric
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Tea Figuric
 *  tea@figuric.net
 *  http://www.figuric.net/luc/facebook/rockband/xml/
 */
require_once 'facebook.php';

$appapikey = '9752009149dbf44a1433290dbb5f0c1d';
$appsecret = '17b29355b24ecffc1b68cefdf559b783';
$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();

$appcallbackurl = 'http://www.figuric.net/luc/facebook/rockband/';
$appstandardurl = 'http://apps.facebook.com/rockbandstats/';

//catch the exception that gets thrown if the cookie has an invalid session_key in it
try {
  if (!$facebook->api_client->users_isAppAdded()) {
    $facebook->redirect($facebook->get_add_url());
  }
} catch (Exception $ex) {
  //this will clear cookies for your application and redirect them to a login prompt
  $facebook->set_user(null, null);
  $facebook->redirect($appcallbackurl);
}
?>